package lostland.gmud.exv2.js;

import android.os.Bundle;

import lostland.gmud.exv2.Gmud;
import lostland.gmud.exv2.data.MainChar;
import lostland.gmud.exv2.data.Npc;
import lostland.gmud.exv2.ui.TalkingScreen;
import lostland.gmud.exv2.ui.core.YesNoScreen;

/**
 * Created by 12548 on 2015/9/13.
 */
public class JsRoom {
	private JsRoom(){};
	private static JsRoom _instance;
	public static JsRoom getInstance(){
		if(_instance == null)
			_instance = new JsRoom();
		return _instance;
	}

	public Bundle currentArgs = new Bundle();

	public LinearScriptScreen currentLSS;

	public String TEST_STRING = "hello JS!";

	public Npc npc(int id) {
		return Gmud.getNpc(id);
	}

	public MainChar mc(){
		return Gmud.mc;
	}

	public void putTalking(String msg){
		new TalkingScreen(msg).pushToGame();
	}

	public void putYesNo(String msg, final int onYes, final int onNo){
		new YesNoScreen(msg){
			@Override
			protected void onYes() {
				if(currentLSS != null){
					currentLSS.line = onYes;
					this.removeFromGame();
				}
			}

			@Override
			protected void onNo() {
				if(currentLSS != null){
					currentLSS.line = onNo;
					this.removeFromGame();
				}
			}
		}.pushToGame();
	}
}
